package com.gusil.orderservice.controller;

import com.gusil.commonmodule.entity.OrderEntity;
import com.gusil.orderservice.feign.PointServiceFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/order")
@RefreshScope
public class OrderController {

    @Value("${config.info}")
    private String configInfo;

    @Autowired
    private PointServiceFeignClient pointServiceFeignClient;

    @GetMapping(value = "/test")
    public String test() {
        return "test";
    }

    @GetMapping("/test/getConfigInfo")
    public String getConfigInfo() {
        return configInfo;
    }

    @PostMapping(value = "/add")
    public String addOrder() {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setId(1);
        orderEntity.setProductionName("水杯");
        return pointServiceFeignClient.addPoint(orderEntity);
    }

    @PostMapping(value = "/add2")
    public String addOrder2() {
        return pointServiceFeignClient.addPoint2("火被");
    }
}